-
Notifications
You must be signed in to change notification settings - Fork 10
Add rule for Link to not be allowed without href #364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 024794c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new ESLint rule to enforce accessibility best practices by preventing the use of Link
components from @primer/react
without an href
attribute. The rule suggests using a Button
component instead for interactive elements that don't navigate to a URL.
- Implements new rule
enforce-button-for-link-with-nohref
to detect Link components without href attributes - Provides comprehensive test coverage for valid and invalid usage scenarios
- Includes proper error messaging and rule metadata configuration
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
src/rules/enforce-button-for-link-with-nohref.js | Main rule implementation that checks for Link components without href attributes |
src/rules/tests/enforce-button-for-link-with-nohref.test.js | Test suite covering valid and invalid usage scenarios |
url: url(module), | ||
}, | ||
messages: { | ||
noLinkWithoutHref: |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
noLinkWithoutHref: | ||
'Links without href and other side effects are not accessible. Use a Button instead.', | ||
}, | ||
fixable: 'code', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rule is marked as fixable but no fix function is implemented. Either implement the fix logic or remove the 'fixable' property.
Copilot uses AI. Check for mistakes.
If a
Link
component from@primer/react
is used without anhref
attribute, it is now flagged as an error."Links without href and other side effects are not accessible. Use a Button instead."